<html>
<head><meta charset="utf-8"><title>MIR and await/async · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/MIR.20and.20await.2Fasync.html">MIR and await/async</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206285522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/MIR%20and%20await/async/near/206285522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> xd009642 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/MIR.20and.20await.2Fasync.html#206285522">(Aug 07 2020 at 17:29)</a>:</h4>
<p>So it's recommended that in async you don't block the scheduler because then your futures won't be polled and in tokio (at least) you should use spawn_blocking for computationally intensive code. And a vague rule of thumb I was told in the tokio discord is anything over 10ms should be in a spawn_blocking. </p>
<p>So I was thinking of trying to identify the largest set of statements between await calls in a single thread and whether I could use MIR to do that analysis? I have a feeling the async await stuff might have been reduced to statemachines at this point so I'm possibly barking up the wrong tree.</p>



<a name="206286170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/MIR%20and%20await/async/near/206286170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/MIR.20and.20await.2Fasync.html#206286170">(Aug 07 2020 at 17:33)</a>:</h4>
<p>async await gets turned into state machines by a mir pass: <a href="https://github.com/rust-lang/rust/blob/4d4342347b71313258a46e506ee0a258f365185c/src/librustc_mir/transform/mod.rs#L438">https://github.com/rust-lang/rust/blob/4d4342347b71313258a46e506ee0a258f365185c/src/librustc_mir/transform/mod.rs#L438</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>